
/* AJAX */
function ajax(url,getOrPost,postVar){
	var xhr; 
	try{xhr = new ActiveXObject('Msxml2.XMLHTTP');}
	catch(e){
		try{xhr = new ActiveXObject('Microsoft.XMLHTTP');}
		catch(e2){
			try{xhr = new XMLHttpRequest();}
			catch(e3){xhr = false;}
		}
	}
	
	switch(getOrPost){
	    default:
	    case "get":
		xhr.open("GET", url, false);
		xhr.send(null);
		break;
	    
	    case "post":
		xhr.open("POST", url, false);
		var postSend = null;
		for(var key in postVar){
		    (postSend == null) ? postSend = "" : postSend += "&";
		    postSend += key+"="+postVar[key];
		}
		if(postSend != null){
		    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		    xhr.setRequestHeader("Content-length", postSend.length);
		    xhr.setRequestHeader("Connection", "close");
	
		}
		xhr.send(encodeURI(postSend));
		break;
	}

	if(xhr.readyState  == 4){
		if(xhr.status  == 200) 
			return(xhr.responseText); 
		else 
			return(false);
	}else
		return(false);	
}


/* OnLoad */
//Cette fonction permet de combler les problemes de
//window.onload des différents navigateurs

function loadJSFunction(function_object){
	if (navigator.appName=="Microsoft Internet Explorer"){
		window.onload += function_object; 
	}else{
		if (navigator.appName=="Netscape"){ //google chrome app.Name
			setTimeout(function_object,10);
		}else{
			window.onload += function_object; // helps with Opera
		}
	}
}